<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
</head>
<body>
    <script>
        // 从后往前3个一段
      var money = '1344534243546';//1,344,534,243,546
      var hexColor = '#ffffff';//[255,255,255]
      var rgbColor = 'rgb(255,0,255)';//[255,0,255]
      console.log(rgbColor.slice(4,-1).split(',').map(function (v) {return +v}));
      console.log(rgbColor.match(/\d{1,3}/g));//["255","0","255"]
      console.log(hexColor.match(/[0-9a-f]{2}/g).map(function (value,index,array) {
          return parseInt(value,16);
      }));//[255,255,255]
      // var arr = [1,2,3];
      // for(var i = 0;i<arr.length;i++){
      //     arr[i] = arr[i] * arr[i];
      // }
      // console.log(arr);
      //   var arr = [1,2,3];
      //   var arr1 = arr.map(function (value,key,array) {
      //      return value * value;
      //   })
      //   console.log(arr1);
      //   非数字[^0-9]
        var telReg = /^1[35789]\d{9}$/;
        console.log(telReg.test('17773323219'));
        var tel = /^1[357-9]\d{9}$/;
        console.log(tel.test('10773323219'));
        var reg1 = /^[^abc]{3}$/;
        console.log(reg1.test('add'));
        var reg2 = /^[a-z]$/;
        console.log(reg2.test('a'));
        var reg3 = /^[a-z]{1,3}$/i;//i忽略大小写
        console.log(reg3.test('ZZ'));//true
        console.log(reg3.test('A'));//true
        console.log(reg3.test('aaa'));//true
        console.log(reg3.test('aaaa'));//false
        var email1 = 'www.3313207858@qq.com';
        var email2 = '3313207858@qq.com';
        // 出现的次数{}
        // {1}忽略不写
        // {1,3}1到3次
        // {0,1}可有可无 ？
        // {1,}1到无穷 若干次 +
        var emailReg = /^(w{3}\.)?3313207858@qq\.com$/;
        console.log(emailReg.test(email1));
        console.log(emailReg.test(email2));
        console.log(/^[a-z0-9A-Z!]+$/.test(''));//false 0次
        console.log(/^[a-z0-9A-Z!]+$/.test('1'));//true
        console.log(/^\**$/.test('*********'));//;匹配*任意次 //true
        console.log(/^\.*$/.test('.'));//任意字符任意次 //true
        console.log(/[zf]ood/.test('food'));//true
        console.log(/[zf]ood/.test('zood'));//true
        // var colorStr = '#fff';
        var colorStr = '#ffffff';
        console.log(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(colorStr));
        var bstr = 'hello world ; edhellofdsd';
        var numstr = 'edddffdedfs32178dfvds187178fcvd112';
        console.log(numstr.match(/\d+/));//32178
        console.log(numstr.match(/\d+/g));//32178  187178  112
        console.log(bstr.match(/\bhello\b/g));
        var bstr = 'hello world ; edhdddofdsd';
        console.log(bstr.match(/\B[a-z]{4}o\B/ig));
        console.log(/\w/.test('q'));
        console.log(/\W/.test('q'));
    </script>
</body>
</html>